package com.party.core.service.count.impl;

import com.party.core.exception.BusinessException;
import com.party.core.model.system.TargetType;
import com.party.core.service.count.IModuleCountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 模块管理器工程
 * Created by wei.li.
 *
 * @date 2017/12/22 0022
 * @time 11:38
 */

@Service
public class ModuleCountFactory {

    @Resource(name = "activityCountService")
    private IModuleCountService activityCountService;

    @Resource(name = "articleCountService")
    private IModuleCountService articleCountService;

    @Resource(name = "projectCountService")
    private IModuleCountService projectCountService;

    @Resource(name = "goodsCountService")
    private IModuleCountService goodsCountService;


    public IModuleCountService getModuleCount(String type){
        if (TargetType.ACTIVITY.getCode().equals(type)){
            return activityCountService;
        } else if (TargetType.ARTICLE.getCode().equals(type)){
            return articleCountService;
        } else if (TargetType.ZC_ACTIVITY.getCode().equals(type)){
            return projectCountService;
        } else if (TargetType.GOODS.getCode().equals(type)){
            return goodsCountService;
        }
        else {
            throw new BusinessException("业务类型不正确");
        }
    }
}
